<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('上架规则管理')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">规则名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="gzmc" lay-verify="required" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal search_btn" lay-event="searchEvent" data-type="reload">查询</a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-primary" style="background-color: #40AFFE">重置</button>
                    </div>
                </form>
                <div class="group-button tpl-button" id="toolbar">
                </div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>

<div id="addRule" style="display: none">
    <form class="layui-form" action="" id="addForm" lay-filter="addForm" style="padding-top: 20px;">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label-div">规则代码</label>
                <div class="layui-input-inline">
                    <input type="tel" name="gzdm" lay-verify="required" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label-div">规则名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="gzmc" lay-verify="required" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label-div">规则描述</label>
                <div class="layui-input-inline">
                    <input type="tel" name="gzms" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
    </form>
</div>
</body>
<style>
    .layui-form-label-div {
        float: left;
        display: block;
        padding: 9px 15px;
        width: 100px;
        font-weight: 400;
        line-height: 20px;
        text-align: right;
    }
    .layui-layer-page .layui-layer-content {
        position: relative;
        overflow: visible !important;
    }
</style>
<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>
<script th:inline="javascript">
    var functions = [[${functions}]];
    layui.use(['layer','zzpUtils','jquery','form','tablebutton'],function(){
        var $ = layui.jquery,
            zzpUtils = layui.zzpUtils,
            form = layui.form,
            tablebtn = layui.tablebutton
            table;
        zzpUtils.webSocket.init({});
        tablebtn.buildOnClick({
            type:1,
            temp:$("#function_tpl"),
            functions: functions.headBtn,
            row:null,
            event:{
                searchEvent: function () {
                    zzpUtils.refreshTable("#table");
                },
                addEvent: function (data) {
                    addDialog();
                },
                editEvent: function(data){
                    console.log("修改",data);
                }
            }
        });
        var columns=[
                {
                    field:'gzdm',
                    title:'规则代码'
                },
                {
                    field:'gzmc',
                    title:'规则名称'
                },
                {
                    field:'gzms',
                    title:'规则描述'
                }
            ];
        table=zzpUtils.table({
            elem: '#table',
            isApi: true,
            isOperate: false,
//            functions: functions.tableBtn,
            url: "/wmsShelfRule/list",
            columns: columns,
            queryParams: function () {
                return zzpUtils.getFormJson($("#searchForm"));
            }
        });

        function addDialog(){
            zzpUtils.dialogBtn.init({
                title: "新增上架规则",
                area: ['auto', 'auto'],
                content: $("#addRule"),
                form: $("#addForm"),
                submit: function (index, msgindex, layero, data) {
                    //添加方法
                    console.log(JSON.stringify(data.field));
                    zzpUtils.action({
                        url: '/wmsShelfRule/add',
                        data: JSON.stringify(data.field),
                        success: function (msg) {
                            var res = zzpUtils.successMsg(msg);
                            if (res != false) {
                                layer.close(msgindex);
                                layer.close(index);
                            }
                        }
                    });
                },
                clear: function () {
                    zzpUtils.refreshTable("#table");
                    $("form input").val("");
                }
            });

//            /wmsShelfRule/add
        }
    });
</script>